<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<input id="IDNumber" type="text" />
<input id="Button2" type="button" value="计算" onclick="Calculate();" />
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script type="text/javascript">
  function IdCard(UUserCard) {
      //获取出生日期
      return UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
  }

  function Calculate() {
    var id = document.getElementById("IDNumber").value;
    var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    var ID = $('#IDNumber').val();
    console.log(ID.substring(6, 10) + "-" + ID.substring(10, 12) + "-" + ID.substring(12, 14));
    return ID.substring(6, 10) + "-" + ID.substring(10, 12) + "-" + ID.substring(12, 14);

  }
</script>
</body>
</html>